package com.mm.controller;

import com.mm.pojo.User;
import com.mm.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.sql.DataSource;

/**
 * @author XiaoLuo
 * @ClassName: HelloController
 * @Description: ${todo}
 * @date 2019/4/4 20:43
 */
@Controller
@RequestMapping("hello")
public class HelloController{


	@Autowired
	private UserService userService;

	/**
	 * 根据用户ID查询用户信息
	 * @param id
	 * @return
	 */
	@GetMapping("user/{id}")
	@ResponseBody
	public User queryUserById(@PathVariable("id") Long id){
		User user = this.userService.queryUserById(id);
		if (user != null) {
			return user;
		}

		return null;
	}
}
